﻿<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>

<script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">数据列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">数据管理</a>
                </li>
                <li class="breadcrumb-item active">数据列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <h4 class="example-title">数据查询</h4>
                    <div class="row">
                        <div id="div_FangYuanKeHuGuanLianId" style="display:none;"></div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">客户名称</label>
                            <input type="text" class="form-control" id="ipt_kehumingcheng" name="" placeholder="请输入客户名称" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">手机号</label>
                            <input type="text" class="form-control" id="ipt_shoujihao" name="" placeholder="请输入人手机号" autocomplete="off" />
                        </div>
                        @*<div class="form-group col-sm-3">
                                <label class="control-label" for="inputBasicPassword">人员名称</label>
                                <input type="text" class="form-control" id="ipt_renyuanmingcheng" name="" placeholder="请输入人员名称" autocomplete="off" />
                            </div>*@
                        <div class="form-group col-sm-4" style="padding-top:27px">
                            <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 45%; float: left;" onclick="ChaXun()"><i class="icon wb-search"></i>查询</button>
                            <span style="padding-left:10%"></span>
                            <button typeutton" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 45%;" onclick="chongzhi();">重置</button>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>房源信息</th>
                                <th>客户姓名</th>
                                <th>手机号码</th>
                                <th>成交金额</th>
                                <th>房源状态</th>
                                <th>销售状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th>房源信息</th>
                                <th>客户姓名</th>
                                <th>手机号码</th>
                                <th>成交金额</th>
                                <th>房源状态</th>
                                <th>销售状态</th>
                                <th>操作</th>
                            </tr>
                        </tfoot>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade example-modal-lg" id="exampleFormModal" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 80%">
        <div class="modal-content" style="width: 100%; height: 90%">
            <div id="nb" hidden="hidden" class="card mb-4" style="right: 0px; left: 0px; -webkit-animation: showSweetAlert .3s; animation: showSweetAlert .3s; margin: 11%; text-align: center; position: fixed; bottom: 40%; border-top-left-radius: 20px; border-top-right-radius: 20px; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; z-index: 1 ">
                <img style="margin-left: 20px; margin-right: 20px;height: 200px;" src="~/GoTRI/img/1889835.gif" />
            </div>
            <div class="modal-header" style="background-color:#0099FF">
                <label id="CunId" style="display:none"></label>
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu" onclick="guanbi()" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="exampleFormModalLabel">修改客户状态</h4>
            </div>
            <div class="row">
                <input type="text" id="IptId" name="name" style="display:none" value="" />
                <input type="text" id="IptPanDuan" name="name" style="display:none" value="" />
                <div class="form-group col-sm-12"></div>

                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-5">
                    <label class="col-form-label" for="for_XingBie">战区</label>
                    <select id="SelZhanQu" class="form-control">
                        <option value="0">请选择</option>
                    </select>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-form-label" for="for_XingBie">战队</label>
                    <select id="SelZhanDui" class="form-control">
                        @*<option value="0">请选择</option>*@
                    </select>
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-5">
                    <label class="control-label" for="inputBasicPassword">业务员</label>
                    <select class="form-control" id="i_sls_yewuyuan" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-5">
                    <label class="control-label" for="inputBasicPassword">置业顾问</label>
                    <select class="form-control" id="i_sls_zhiyeguwen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">小区名称</label>
                    <select class="form-control" id="selxiaoqu" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">楼号</label>
                    <select class="form-control" id="sellouhao" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">层</label>
                    <select class="form-control" id="selceng" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">门</label>
                    <select class="form-control" id="selmen" name="" data-fv-notempty="true" data-fv-field="requiredSelect"></select>
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-1" style="margin: 5px 0px"></div>
                <div class="form-group col-sm-10" style="margin: 5px 0px">
                    <label class="control-label" for="inputBasicPassword">房源状态:</label>
                    <label class="control-label" for="inputBasicPassword" id="zhuangtai"></label>
                </div>
                <div class="form-group col-sm-1" style="margin: 5px 0px"></div>


                <div class="form-group col-sm-1"></div>
                <div class="form-group col-sm-10">
                    <label class="control-label" for="inputBasicPassword">成交金额</label>
                    <input type="text" name="asdf" id="iptmoney" class="form-control" value="" />
                </div>
                <div class="form-group col-sm-1"></div>


                <div class="form-group col-sm-3"></div>
                <div class="form-group col-sm-6">
                    <button type="button" id="bt_ChongZhiE" class="btn btn-outline btn-success" style="width: 100%;" onclick="SubmitUpdate();">确定</button>
                </div>
                <div class="form-group col-sm-3"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SpanShuJu").click();
        BindSelXiaoQu();
        BindDpZhanQu();

        //修改下拉框绑定1
        $('#SelZhanQu').bind('input propertychange', function () {
            $("#SelZhanDui").empty();
            $("#i_sls_yewuyuan").empty();
            $.ajax({
                url: "../RenYuan/GetSelZhanDui",
                data: { "ZhanQuId": $("#SelZhanQu").val() },
                type: "post",
                dataType: "json",
                success: function (response) {
                    if ($("#SelZhanQu").val() != 0) {
                        var ddl = $("#SelZhanDui");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        if (response[key].id.toString() == '1') {
                            var opt = $("<option></option>").text("请选择").val(response[key].id);
                            ddl.append(opt);
                        } else if (response[key].id.toString() == "") {
                            var opt = $("<option selected='selected'></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        } else {
                            var opt = $("<option></option>").text(response[key].ZhanDuiMingCheng).val(response[key].id);
                            ddl.append(opt);
                        }
                    })
                    console.log(response);
                }
            });
        })
        //修改下拉框绑定1
        $('#SelZhanDui').bind('input propertychange', function () {
            $("#i_sls_yewuyuan").empty();
            yiwuyuan();
        })

        yiwuyuan()
        zhiyeguwen();

        //修改下拉框绑定3
        $('#selxiaoqu').bind('input propertychange', function () {
            $("#sellouhao").empty();
            $("#selceng").empty();
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelLouHao",
                type: "post",
                data: { "XiaoQuId": $("#selxiaoqu").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#selxiaoqu").val() != 0) {
                        var ddl = $("#sellouhao");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].LouHao + "号楼").val(response[key].LouHao);
                        ddl.append(opt);
                    })
                }
            });
        })
        //修改下拉框绑定3
        $('#sellouhao').bind('input propertychange', function () {
            $("#selceng").empty();
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelCeng",
                type: "post",
                data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#sellouhao").val() != 0) {
                        var ddl = $("#selceng");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].Ceng + "层").val(response[key].Ceng);
                        ddl.append(opt);
                    })
                }
            });
        })
        //修改下拉框绑定3
        $('#selceng').bind('input propertychange', function () {
            $("#selmen").empty();
            $("#zhuangtai").text("");
            $.ajax({
                url: "../KeHu/BindSelMen",
                type: "post",
                data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val() },
                dataType: "json",
                success: function (response) {
                    if ($("#selceng").val() != 0) {
                        var ddl = $("#selmen");
                        var opt0 = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt0);
                    }
                    $(response).each(function (key) {
                        var opt = $("<option></option>").text(response[key].Men + "门").val(response[key].Men);
                        ddl.append(opt);
                    })
                }
            });
        })


        $("#SpanShuJu").click();
        //修改下拉框事件3 调用房源状态
        document.getElementById('selmen').onchange = function () {
            if ($("#selmen").find("option:selected").val() != 0) {
                zhuangtai2();
            } else {
                $("#zhuangtai").text("");
            }

        };
        //$("#SpanShuJu").click();
        var KeHuXingMing = $("#ipt_kehumingcheng").val();
        var DianHuaHaoMa = $("#ipt_shoujihao").val();
        bang(KeHuXingMing, DianHuaHaoMa);
    })

    //查询
    function ChaXun() {
        var KeHuXingMing = $("#ipt_kehumingcheng").val();
        var DianHuaHaoMa = $("#ipt_shoujihao").val();
        bang(KeHuXingMing, DianHuaHaoMa);
    }
    //绑定公司列表
    function bang(KeHuXingMing, DianHuaHaoMa) {

        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[0, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                console.log(data);
                var param = {};
                param.sw = "";
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;
                param.KeHuXingMing = KeHuXingMing;
                param.DianHuaHaoMa = DianHuaHaoMa;

                console.log(param);

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: '../KeHu/BindFangYuanKeHuGuanLian',
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "XiaoQuMingCheng", render: function (data, type, row) { return "<label>" + FangYuanXinXi(row.XiaoQuMingCheng, row.LouHao, row.Ceng, row.Men) + "</label>" } },
                { "data": "KeHuXingMing" },
                { "data": "ShouJiHaoMa" },
                { "data": "ChengJiaoJinE" },
                { "data": "ZhuangTai" },
                { "data": "BeiZhu1" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    return '<a title = "" id="aid" data-target="#exampleFormModal" class="" data-toggle="modal" id="btn_Xz"><i class="" aria-hidden="true"></i><button id="' + row.Id + '" style="background-color:#00BFFF;color:#ffffff" type="button" class="btn btn-outline btn-default"  onclick="XiuGai(' + row.Id + ',' + row.XiaoQuId + ',' + row.LouHao + ',' + row.Ceng + ',' + row.Men + ',' + row.ChengJiaoJinE + ')">修改</button> </a>';
                }
            }]
        })
    }


    //弹层绑定单元
    function BindDong() {
        $("#sellouhao").empty();
        $.ajax({
            url: "../KeHu/BindSelLouHao",
            type: "post",
            async: false,
            data: { "XiaoQuId": $("#selxiaoqu").val() },
            dataType: "json",
            success: function (response) {
                var ddl = $("#sellouhao");
                var opt0 = $("<option></option>").text("请选择").val(0);
                ddl.append(opt0);
                console.log(response);
                $(response).each(function (key) {
                    var opt = $("<option></option>").text(response[key].LouHao + "号楼").val(response[key].LouHao);
                    ddl.append(opt);
                })


            }
        });
    }
    //弹层绑定层
    function BindCeng() {
        $("#selceng").empty();
        $.ajax({
            url: "../KeHu/BindSelCeng",
            type: "post",
            async: false,
            data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val() },
            dataType: "json",
            success: function (response) {
                var ddl = $("#selceng");
                var opt0 = $("<option></option>").text("请选择").val(0);
                ddl.append(opt0);
                $(response).each(function (key) {
                    var opt = $("<option></option>").text(response[key].Ceng + "层").val(response[key].Ceng);
                    ddl.append(opt);
                })
            }
        });
    }
    //弹层绑定们
    function BindMen() {
        $("#selmen").empty();
        $.ajax({
            url: "../KeHu/BindSelMen",
            type: "post",
            async: false,
            data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val() },
            dataType: "json",
            success: function (response) {
                var ddl = $("#selmen");
                var opt0 = $("<option></option>").text("请选择").val(0);
                ddl.append(opt0);
                $(response).each(function (key) {
                    var opt = $("<option></option>").text(response[key].Men + "门").val(response[key].Men);
                    ddl.append(opt);
                })
            }
        });
    }
    //弹层绑定
    function XiuGai(Id, XiaoQuId, Dong, Ceng, Men, ChengJiaoJinE) {
        $("#div_FangYuanKeHuGuanLianId").text(Id)
        $("#selxiaoqu").find("option[value='" + XiaoQuId + "']").attr("selected", true);

        BindDong();
        $("#sellouhao").find("option[value='" + Dong + "']").attr("selected", true);
        BindCeng();
        $("#selceng").find("option[value='" + Ceng + "']").attr("selected", true);
        BindMen();
        $("#selmen").find("option[value='" + Men + "']").attr("selected", true);

        zhuangtai2()

        $("#iptmoney").val(ChengJiaoJinE);

        yiwuyuan(Id);
        zhiyeguwen(Id);
    }

    //显示房源状态
    function zhuangtai2() {
        $.ajax({
            type: "POST",
            url: "../KeHu/fangyuanzhuangtai",
            cache: false,  //禁用缓存
            data: { "LouHao": $("#sellouhao").val(), "XiaoQuId": $("#selxiaoqu").val(), "Ceng": $("#selceng").val(), "Men": $("#selmen").val() },  //传入组装的参数
            dataType: "text",
            success: function (result) {
                $("#zhuangtai").text(result);
                if (result != "未出售") {
                    $("#bt_ChongZhiE").attr("disabled", "disabled");
                } else {
                    $("#bt_ChongZhiE").removeAttr("disabled", "disabled");
                }
            }
        })
    }
    //信息 修改
    function SubmitUpdate() {
        var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if ($("#i_sls_yewuyuan").val() == "请选择" || $("#i_sls_yewuyuan").val() == undefined || $("#i_sls_yewuyuan").val() == "") {
            alert('请选择业务员！');
        } else if ($("#selxiaoqu").val() == "请选择" || $("#selxiaoqu").val() == undefined || $("#selxiaoqu").val() == "") { 
            alert('请选择小区！');
        } else if ($("#sellouhao").val() == "请选择" || $("#sellouhao").val() == undefined || $("#sellouhao").val() == "") {
            alert('请选择楼号！');
        } else if ($("#selceng").val() == "请选择" || $("#selceng").val() == undefined || $("#selceng").val() == "") {
            alert('请选择层！');
        } else if ($("#selmen").val() == "请选择" || $("#selmen").val() == undefined || $("#selmen").val() == "") {
            alert('请选择门！');
        } else if (!reg.test($("#iptmoney").val())) {
            alert('请输入正确金额！');
        } else {
            //$("#nb").removeAttr("hidden");
            $("#bt_ChongZhiE").attr("disabled", "disabled");


            $.ajax({
                type: "POST",
                url: "../KeHu/xiaoshouxiugai",
                cache: false,  //禁用缓存
                data: { "GuanLianId": "" + $("#div_FangYuanKeHuGuanLianId").text() + "", "XiaoQuId": "" + $("#selxiaoqu").val() + "", "Dong": "" + $("#sellouhao").val() + "", "Ceng": "" + $("#selceng").val() + "", "Men": "" + $("#selmen").val() + "", "JinE": "" + $("#iptmoney").val() + "", "yewuyuan": "" + $("#i_sls_yewuyuan").val() + "", "zhiyeguwen": "" + $("#i_sls_zhiyeguwen").val() + "" },  //传入组装的参数
                dataType: "text",
                success: function (result) {

                    if (result == "-1") {
                        //$("#nb").attr("hidden", "");
                        $("#bt_ChongZhiE").attr("disabled", false);
                        swal("成功提示!", "修改成功!", "success");
                        //$("#exampleFormModal").hide();
                        bang('', '');
                    } else if (result == "-2") {
                        swal("失败提示!", "客户失败!", "error");
                    } else if (result == "-3") {
                        swal("失败提示!", "销售失败!", "error");
                    } else if (result == "-4") {
                        swal("失败提示!", "房源1失败!", "error");
                    } else if (result == "-5") {
                        swal("失败提示!", "客户房源失败!", "error");
                    } else if (result == "-6") {
                        swal("失败提示!", "销售详细失败!", "error");
                    } else if (result == "-7") {
                        swal("失败提示!", "房源2失败!", "error");
                    } else {
                        swal("失败提示!", "操作出现异常!", "error");
                    }
                }
            })
        }
    }



    //业务员
    function yiwuyuan(Id) {
        $.ajax({
            url: "../KeHu/Yewuyuan",
            type: "post",
            data: { "SelZhanQu": "" + $("#SelZhanQu").find("option:selected").val() + "", "SelZhanDui": "" + $("#SelZhanDui").find("option:selected").val() + "", "Id": "" + Id + "" },
            dataType: "json",
            success: function (response) {
                var ddl = $("#i_sls_yewuyuan");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt);
                    } else if (response.length == 1) {
                        $("#i_sls_yewuyuan").val(response[key].Id);
                    } else {
                        var opt = $("<option></option>").text(response[key].XingMing).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }
    //置业顾问
    function zhiyeguwen(Id) {
        $.ajax({
            url: "../KeHu/Zhhiyeguwen",
            type: "post",
            data: { "Id": "" + Id + "" },
            dataType: "json",
            success: function (response) {
                var ddl = $("#i_sls_zhiyeguwen");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(0);
                        ddl.append(opt);
                    } else if (response.length == 1) {
                        $("#i_sls_zhiyeguwen").val(response[key].Id);
                    } else {
                        var opt = $("<option></option>").text(response[key].XingMing).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }

    //关闭
    function guanbi()
    {
        $("#SelZhanQu").val(0);
        $("#SelZhanDui").empty();
        $("#i_sls_yewuyuan").val("");
        yiwuyuan();
    }
    //重置
    function chongzhi() {
        $("#ipt_kehumingcheng").val('');
        $("#ipt_shoujihao").val('');
        bang('', '');
    };

    //战区绑定
    function BindDpZhanQu() {
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
        $.ajax({
            url: "../RenYuan/GetSelZhanQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#SelZhanQu2");
                $(response).each(function (key) {
                    if (response[key].Id.toString() == '1') {
                        var opt = $("<option></option>").text("请选择").val(response[key].Id);
                        ddl.append(opt);
                    } else {
                        var opt = $("<option></option>").text(response[key].ZhanQuMingCheng).val(response[key].Id);
                        ddl.append(opt);
                    }
                })
                console.log(response);
            }
        });
    }

    function BindSelXiaoQu() {
        $.ajax({
            url: "../KeHu/BindSelXiaoQu",
            type: "post",
            dataType: "json",
            success: function (response) {
                var ddl = $("#selxiaoqu");
                var opt = $("<option></option>").text("请选择").val(0);
                ddl.append(opt);
                $(response).each(function (key) {
                    var opt = $("<option></option>").text(response[key].XiaoQuMingCheng).val(response[key].Id);
                    ddl.append(opt);
                })
                console.log(response);
            }
        });
    }

    function FangYuanXinXi(XiaoQuMingCheng, LouHao, Ceng, Men) {
        return XiaoQuMingCheng + LouHao + "号楼" + Ceng + "层" + Men + "门";
    }

</script>
